home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / foomatic-db.postinst < prev    next >
Text File  |  2009-10-08  |  3KB  |  85 lines

  1. #! /bin/sh
  2. # postinst script for foomatic-db
  3. # $Id: $
  4. #
  5. # see: dh_installdeb(1)
  6.  
  7. set -e
  8.  
  9. # summary of how this script can be called:
  10. #        * <postinst> `configure' <most-recently-configured-version>
  11. #        * <old-postinst> `abort-upgrade' <new version>
  12. #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
  13. #          <new-version>
  14. #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
  15. #          <failed-install-package> <version> `removing'
  16. #          <conflicting-package> <version>
  17. # for details, see http://www.debian.org/doc/debian-policy/ or
  18. # the debian-policy package
  19. #
  20. # quoting from the policy:
  21. #     Any necessary prompting should almost always be confined to the
  22. #     post-installation script, and should be protected with a conditional
  23. #     so that unnecessary prompting doesn't happen if a package's
  24. #     installation fails and the `postinst' is called with `abort-upgrade',
  25. #     `abort-remove' or `abort-deconfigure'.
  26.  
  27. case "$1" in
  28.     configure)
  29.         # Do the following only if CUPS is running and the needed CUPS tools
  30.         # are available
  31.     if which lpstat > /dev/null 2>&1 && \
  32.         which lpinfo > /dev/null 2>&1 && \
  33.         which lpadmin > /dev/null 2>&1 && \
  34.         LC_ALL=C lpstat -h /var/run/cups/cups.sock -r | grep -v not > /dev/null 2>&1; then
  35.          # Update the PPD files of all already installed print queues
  36.         driverregexp='^foomatic:'
  37.         gennicknameregexp='s/Foomatic\/hpijs-\w+\b/Foomatic\/hpijs/'
  38.         [ ! -z "$gennicknameregexp" ] && \
  39.         gennicknameregexp="; $gennicknameregexp"
  40.         gennicknameregexp='s/\s*\(recommended\)//'"$gennicknameregexp"
  41.         tempfiles=
  42.         trap 'rm -f $tempfiles; exit 0' 0 HUP INT QUIT ILL ABRT PIPE TERM
  43.         tmpfile1=`mktemp -t updateppds.XXXXXX`
  44.         tempfiles="$tempfiles $tmpfile1"
  45.         lpinfo -h /var/run/cups/cups.sock -m | grep -E $driverregexp > $tmpfile1
  46.         cd /etc/cups/ppd
  47.         for ppd in *.ppd; do
  48.         [ -r "$ppd" ] || continue
  49.         queue=${ppd%.ppd}
  50.         lpstat -h /var/run/cups/cups.sock -p "$queue" >/dev/null 2>&1 || continue
  51.         nickname=`grep '\*NickName:' "$ppd" | cut -d '"' -f 2 | perl -p -e 's/\n$//' | perl -p -e "$gennicknameregexp" | perl -p -e 's/(\W)/\\\\$1/g'`
  52.         lang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  53.         ppdfound="0"
  54.         englishppduri=""
  55.         tmpfile2=`mktemp -t updateppds.XXXXXX`
  56.         tempfiles="$tempfiles $tmpfile2"
  57.         cat $tmpfile1 | perl -p -e "$gennicknameregexp" | grep -E '^\S+\s+.*'"$nickname"'$' | cut -d ' ' -f 1 > $tmpfile2
  58.         while read newppduri; do
  59.             [ "$ppdfound" = "0" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $newppduri 2>/dev/null || continue
  60.             newlang=`grep '\*LanguageVersion:' "$ppd" | cut -d ' ' -f 2 | perl -e 'print lc(<>)' | perl -p -e 's/[\r\n]//gs'`
  61.             [ "$newlang" = "$lang" ] && ppdfound="1"
  62.             [ "$newlang" = "english" ] && englishppduri="$newppduri"
  63.         done < $tmpfile2
  64.         [ "$ppdfound" = "0" ] && [ ! -z "$englishppduri" ] && lpadmin -h /var/run/cups/cups.sock -p "$queue" -m $englishppduri 2>/dev/null && ppdfound="1"
  65.         [ "$ppdfound" = "1" ] && echo PPD for printer $queue updated >&2
  66.         done
  67.     fi
  68.     ;;
  69.  
  70.     abort-upgrade|abort-remove|abort-deconfigure)
  71.     ;;
  72.  
  73.     *)
  74.         echo "postinst called with unknown argument \`$1'" >&2
  75.         exit 1
  76.     ;;
  77. esac
  78.  
  79. # dh_installdeb will replace this with shell code automatically
  80. # generated by other debhelper scripts.
  81.  
  82.  
  83.  
  84. exit 0
  85.